#include <iostream>

using namespace std;

const int N = 1010;
int b[N][N], a[N];
int n;

int main()
{
	cin >> n;
	for(int i = 1; i <= n ; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			cin >> b[i][j];
		}
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(b[i][j] != 0)
			a[i] |= b[i][j];
		}
	}
	for(int i = 1; i <= n; i++) cout << a[i] << " ";
	return 0;
}
